- Create Dockerfile
# Select CUDA version (https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda/tags)
From nvcr.io/nvidia/cuda:10.1-cudnn8-devel-ubuntu18.04
# Modify the Language and the encoding methods of the OS
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
# Install vim, git, zsh, wget, openssh-server
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y locales git vim nano zsh wget openssh-server && rm -rf /var/lib/apt/lists/*
# Setup SSH, password, expose 22
RUN mkdir /var/run/sshd
RUN echo 'root:qwerty' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
# Modify the default sh from bash to zsh
RUN usermod -s /bin/zsh root
# Install Miniconda
COPY ./conda/Miniconda3-latest-Linux-x86_64.sh /opt/Miniconda3-latest-Linux-x86_64.sh
RUN bash /opt/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda
RUN rm -f /opt/Miniconda3-latest-Linux-x86_64.sh
ENV PATH /opt/conda/bin:$PATH
RUN /opt/conda/bin/conda init zsh
ENTRYPOINT service ssh start && zsh
- Build Image
docker build -t cuda:10.1-cudnn8-devel-ubuntu18.04-conda .
- Create Container in Portainer UI
- Connect to the Container
ssh [email protected] -p 1998
- Create Virual Python Environment
conda create -n SRIR python=3.8
conda activate SRIR
- Install pytorch and torchvision
cd /mingzailao-data/dockerfile/mingzailao-torch/torch-whl
# Warnning: Select the right torch version and torchvision version based on this: https://pytorch.org/get-started/previous-versions/
pip install ./torch-1.6.0+cu101-cp38-cp38-linux_x86_64.whl
# if not exist, download it by wget then install it
wget https://download.pytorch.org/whl/cu101/torchvision-0.7.0%2Bcu101-cp38-cp38-linux_x86_64.whl#sha256=40527f2c6db0e8b7c4408d46be78ce13644f59ad76f9be098ac32d2805f23204
pip install ./
7. Open VSCode and install Python Plugin and select python interpreter
DONE!!!
Solve libGL of opencv
pip uninstall opencv-python
pip install opencv-python-headless